package org.hghog.jlinkdemo;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.stage.Stage;
import org.hghog.jlinkdemo.util.DefaultPath;

import java.io.IOException;
import java.io.InputStream;
import java.util.Objects;

public class HelloApplication extends Application {
    @Override
    public void start(Stage stage) throws IOException {
        FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("hello-view.fxml"));
        Parent load = fxmlLoader.load();
        // 引入全局样式
        load.getStylesheets().add(Objects.requireNonNull(getClass().getResource("global.css")).toExternalForm());
        // 处理默认设置
        DefaultPath.initLastTimePath(load.getChildrenUnmodifiable());

        Scene scene = new Scene(load);

        // 设置主窗口图标
        try {
            InputStream stream = HelloApplication.class.getResourceAsStream("HGhog-ico.png");
            Image image = new Image(stream);
            stage.getIcons().add(image);
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }

        stage.setMinWidth(360);
        stage.setMinHeight(420);
        stage.setMaxWidth(360);
        stage.setMaxHeight(420);

        stage.setTitle("Cut-Video(HGhog)");
        stage.setScene(scene);
        stage.show();
    }

    public static void main(String[] args) {
        launch();
    }
}